namespace jsWrite {
    function myNew(constructor:()=>any,...rest:Array<any>){
        let obj = Object.create(constructor.prototype);
        let result = constructor.apply(obj,rest as any);
        let flag = result && (typeof result === 'object' || typeof result === 'function')
        return flag ? result : obj
    }

    let arr = myNew(Array,1,2,3)
    console.log(Object.getPrototypeOf(arr)===Array.prototype);
}